package me.yricky.chart.content.coordinate

import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import me.yricky.chart.base.CoordinateDatasets
import me.yricky.chart.base.DataRange
import me.yricky.chart.base.Dataset

class ChartTheme{
    var lineColor:Color by mutableStateOf(Color.Gray)
    var cursorColor:Color by mutableStateOf(Color.Red)
    var axisColor:Color by mutableStateOf(Color.Black)
}

@Composable
fun chartTheme(theme: ChartTheme.()->Unit = {}) = remember{ ChartTheme().apply(theme) }



class ChartModifier{
    var xRangeTrans:(DataRange) -> DataRange by mutableStateOf({ it })
    var yRangeTrans:(DataRange) -> DataRange by mutableStateOf({ it })
    var showAxis by mutableStateOf(false)
    var xAxis:(DataRange) -> Double by mutableStateOf({ it.first })
    var yAxis:(DataRange) -> Double by mutableStateOf({ it.first })
}

@Composable
fun chartModifier(mod: ChartModifier.()->Unit = {}) = ChartModifier().apply(mod)

fun <T> coordinateDatasets(
    name:String,
    list:List<T>,
    dataXValue:(T)->Number,
    dataYValue:(T)->Number,
) = CoordinateDatasets(
    datasets = listOf(Dataset(name,list)),
    dataXValue, dataYValue
)